
<template>
  <div class="login">
    <div class="login_box">
      <el-row type="flex" justify="space-between">
        <el-col :span="12">
          <div class="login_box_left">
            <div class="login_box_left_img">
              <img src="../assets/images/bgleft.png" alt />
            </div>
          </div>
        </el-col>
        <el-col :span="14">
          <div class="login_box_right">
            <div class="login_box_left_txt1">ERP采购系统</div>
            <div class="loginbg">
              <el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form">
                <el-form-item prop="username">
                  <el-input
                    v-model="loginForm.username"
                    type="text"
                    auto-complete="off"
                    placeholder="请输入用户名"
                  >
                    <svg-icon slot="prefix" icon-class="user" class="el-input__icon input-icon" />
                  </el-input>
                </el-form-item>
                <el-form-item prop="password">
                  <el-input
                    v-model="loginForm.password"
                    type="password"
                    auto-complete="off"
                    placeholder="请输入密码"
                    @keyup.enter.native="handleLogin"
                  >
                    <svg-icon
                      slot="prefix"
                      icon-class="password"
                      class="el-input__icon input-icon"
                    />
                  </el-input>
                </el-form-item>
                <el-form-item prop="code" v-if="captchaOnOff">
                  <el-input
                    v-model="loginForm.code"
                    auto-complete="off"
                    placeholder="请输入验证码"
                    style="width: 63%"
                    @keyup.enter.native="handleLogin"
                  >
                    <svg-icon
                      slot="prefix"
                      icon-class="validCode"
                      class="el-input__icon input-icon"
                    />
                  </el-input>
                  <div class="login-code">
                    <img :src="codeUrl"  class="login-code-img" />
                  </div>
                </el-form-item>
                <el-checkbox v-model="loginForm.rememberMe" style="margin: 0px 0px 25px 0px">记住密码</el-checkbox>
                <el-form-item style="width: 100%">
                  <el-button
                    :loading="loading"
                    size="medium"
                    type="primary"
                    style="width: 100%"
                    @click.native.prevent="handleLogin"
                  >
                    <span v-if="!loading">登 录</span>
                    <span v-else>登 录 中...</span>
                  </el-button>
                  <div style="float: right" v-if="register">
                    <router-link class="link-type" :to="'/register'">立即注册</router-link>
                  </div>
                </el-form-item>
              </el-form>
            </div>
          </div>
        </el-col>
      </el-row>
    </div>
    <!--  底部  -->
    <!-- <div class="el-login-footer">
      <span>Copyright © 2018-2022 vip All Rights Reserved.</span>
    </div>-->
  </div>
</template>

<script>
export default {
  name: "Login",
  data() {
    return {
      codeUrl: "",
      loginForm: {
        username: "",
        password: "",
        rememberMe: false,
        code: "",
        uuid: ""
      },
      loginRules: {
        username: [
          {
            required: true,
            trigger: "blur",
            message: "请输入您的账号"
          }
        ],
        password: [
          {
            required: true,
            trigger: "blur",
            message: "请输入您的密码"
          }
        ],
        code: [
          {
            required: true,
            trigger: "change",
            message: "请输入验证码"
          }
        ]
      },
      loading: false,
      // 验证码开关
      captchaOnOff: true,
      // 注册开关
      register: false,
      redirect: undefined
    };
  },
  created() {},
  mounted() {},
  methods: {
    handleLogin() {
      this.$router.push('/index');
    }
  }
};
</script>

<style scoped lang="scss">
.login {
  height: 100%;
  background-image: url("../assets/images/bglogo_img.png");
  background-size: 100% 100%;
  background-attachment: fixed;
  display: flex;
  justify-content: center;
  align-items: center;
  .login_box {
    width: 50%;
    height: 550px;
    background: #ffffff;
    border-radius: 5px;
    padding: 0px 40px;
    .login_box_left {
      padding-top: 100px;
      display: flex;
      justify-content: center;
      align-items: center;
      flex-direction: column;

      .login_box_left_img {
        height: 450px;
      }
      .login_box_left_img img {
        width: 100%;
        height: 100%;
      }
    }
    .login_box_right {
      display: flex;
      justify-content: center;
      align-items: center;
      flex-direction: column;
      height: 600px;
      .login_box_left_txt1 {
        font-weight: 700;
        color: #000000;
        font-size: 40px;
        .login_box_left_txt2 {
          font-weight: 500;
          font-size: 24px;
          color: #4e4e4e;
        }
      }
      .login_box_right_txt1 {
        font-weight: 700;
        font-size: 34px;
        color: #0d9bf8;
        text-align: center;
        .login_box_right_txt2 {
          font-weight: 400;
          font-size: 21px;
          color: #b4b4b4;
        }
      }
      .loginbg {
        background: #ffffff;
        width: 460px;
        padding: 10px;
        border-radius: 15px;
        .loginTtile {
          padding: 20px 0;
          width: 100%;
          font-size: 25px;
          font-weight: bold;
          text-align: center;
          color: #ccc;
          span {
            font-weight: normal;
            font-size: 20px;
          }
        }
      }

      .login-form {
        border-radius: 6px;
        width: 440px;
        padding: 50px 25px 25px 25px;
        .el-input {
          height: 38px;
          input {
            height: 38px;
          }
        }

        .input-icon {
          height: 39px;
          width: 14px;
          margin-left: 2px;
        }
      }

      .login-tip {
        font-size: 13px;
        text-align: center;
        color: #bfbfbf;
      }

      .login-code {
        width: 33%;
        height: 38px;
        float: right;

        img {
          width: 100%;
          height: 38px;
          cursor: pointer;
          vertical-align: middle;
        }
      }
    }
  }
}

.el-login-footer {
  height: 40px;
  line-height: 40px;
  position: fixed;
  bottom: 0;
  width: 100%;
  text-align: center;
  color: #000;
  font-family: Arial;
  font-size: 12px;
  letter-spacing: 1px;
}

// .login-code-img {
// 	height: 38px;
// }
</style>
